﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace SpeechBill
{
    class DBHelper
    {
        public static SqlConnection GetCon()
        {
            string s1 = Application.StartupPath;
            string s2 = s1.Substring(0, s1.LastIndexOf("\\"));
            string s3 = s2.Substring(0, s2.LastIndexOf("\\"));
            String constr = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + s3 + "\\SpeechDB.mdf;Integrated Security=True";
            SqlConnection con = new SqlConnection(constr);
            return con;
        }
        public static int ExctInsertDelUp(string cmdText)
        {
            int count = 0;

            SqlConnection con = DBHelper.GetCon();
            con.Open();

            SqlCommand cmd = new SqlCommand(cmdText, con);
            
            count = Convert.ToInt32(cmd.ExecuteNonQuery());
            con.Close();

            return count;
        }
    }
}
